(function ($) {
  "use strict";
  /*
  * author GL
  * params = {
  *   icon 图标,默认为null,没有显示('#icon-question') String
  *   text 内容 String
  *   duration 持续时间 Number
  *   callback 消失后执行的回调 Function
  * }
  * */
  $.toast = function (params) {
    var defaults = {
      icon: null,
      text: 'toast',
      duration: 3000,
      boxPadding: "",
      callback: function () {}
    };
    var params = $.extend({},defaults,params);
    var tpl = '<div class="gzl-toast"><div class="gzl-toast__box">' +
      (params.icon?'<div class="gzl-toast__icon '+(params.boxClass?params.boxClass:'')+'"><svg class="icon" aria-hidden="true"><use xlink:href="'+params.icon+'"></use></svg></div>':'') +
      '<span class="gzl-toast__text">'+params.text+'</span>' +
      '</div></div>';
    if($(".gzl-toast").length<1){
      var toast = $(tpl).appendTo(document.body);
      var box = toast.find(".gzl-toast__box");
      if(box.outerHeight() > .32*$('html').css('font-size')){
        box.addClass("plural");
      }
      box.fadeIn().delay(params.duration-1000).fadeOut();
    }
    setTimeout(function() {
      $(".gzl-toast").remove();
      params.callback();
    }, params.duration);
  }
})($);